/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package uit.tkorg.coauthorgraph.utility;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

/**
 *
 * @author Tien, Cuong
 */
public class CommonHTMLProcessor {

    // ID get Div suggest authors : #ctl00_MainContent_SearchSuggestion_divSearchSuggestion
    // ID to get number of Citation : ctl00_MainContent_AuthorItem_citedBy
    // ID to get number of publi: ctl00_MainContent_AuthorItem_publication
    // ID to get co - author : ctl00_LeftPanel_CoAuthors_PanelHeader
    // ID to get left panel (co - author, Conference,joural, keyword ): ctl00_divLeftWrapper
    public static String getHTMLContentOfDivTag(String htmlContent, String divID) {
    	Element getdata = null;
    	try {
            Document doc = Jsoup.parse(htmlContent);
            String id = "#" + divID;
            getdata = doc.select(id).first();
    	}
    	catch (Exception ex) {
            System.out.print(ex.toString());
    	}

    	if(getdata == null)
            return null;
        return getdata.toString();
    }

    /**
     *
     * @param htmlContent
     * @param divID
     * @return
     */
    public static String getTextOfDivTag(String htmlContent, String divID) {
        Document doc = Jsoup.parse(htmlContent);
        String id = "#"+divID;
        Element getdata = doc.select(id).first();
        
        return getdata.ownText();
    }
}


